package chapter4.demo;

import linklisttest.Link;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author lzy
 * @create 2018-03-16 下午4:22
 */
public class PetShop {
    private Link pets = new Link();

    public void add(Pet pet) {
        pets.add(pet);
    }

    public void delete(Pet pet) {
        pets.remove(pet);
    }

    public Link search(String keyWord) {
        Link result = new Link();
        Object[] objects = this.pets.toArray();

        for (int i = 0; i < objects.length; i++) {
            Pet p = (Pet) objects[i];
            if (p.getName().contains(keyWord)) {
                result.add(p);
            }
        }
        return result;
    }
}
